package com.yan.deezer.activity;
import java.net.MalformedURLException;
import java.net.URL;

import android.util.Log;

public class Implement {
   
    //Episode data properties
    private String title;
    private String date;
    private URL link;
    private String imglink;
    private String description;
   
   
    //Getters and Setters for data
    public void setTitle(String title) {
        this.title = title;
    }
    public String getTitle() {
        return title;
    }
   
    public void setDate(String date) {
        this.date = date;
        Log.d("*******date*********", date.toString());
    }
    public String getDate() {
        return date;
    }
   
    public void setLink(String link) {
        try {
            this.link = new URL(link);
        } catch (MalformedURLException e) {
            e.printStackTrace();
        }
    }
    public URL getLink() {
        return link;
    }
   
    public void setDescription(String description) {
        this.description = description;
       
        //parse description for any image or video links
        if (description.contains("<img ")){
            String img  = description.substring(description.indexOf("<img "));
       
            String cleanUp = img.substring(0, img.indexOf(">")+1);
            img = img.substring(img.indexOf("src=") + 5);
            int indexOf = img.indexOf("'");
            if (indexOf==-1){
                indexOf = img.indexOf("\"");
            }
            img = img.substring(0, indexOf);
           
            setImage(img);
           
            this.description = this.description.replace(cleanUp, "");
        }
    }
    /**
         * @return the description
     */
    public String getDescription() {
        return description;
    }

    public void setImage(String link) {
        this.imglink = new String(link);
        Log.d("*******image*********", imglink.toString());
    }
    public String getImage() {
       
        return imglink;
    }
   

}